package com.shaozi.nc;

import java.io.File;
import java.io.IOException;

import org.apache.commons.lang.StringUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;

import com.shaozi.nc.configuration.AppContextProperties;

@SpringBootApplication
@EnableCaching
@ComponentScan(value = { "com.shaozi.utils", "com.shaozi" })
//@EnableTransactionManagement // 启注解事务管理，等同于xml配置方式的 <tx:annotation-driven />
@EnableConfigurationProperties(value = { AppContextProperties.class })
public class NCRunApp {

	public static void main(String[] args) throws IOException {
		String appPath = System.getProperty("LOGDIR");
		if (StringUtils.isEmpty(appPath)) {
		File f = new File("");
		appPath = f.getCanonicalPath();
		System.setProperty("LOGDIR", appPath);
		}
		System.out.println("app path:" + appPath);
		File file = new File(appPath + "/logs");
		if (!file.exists()) {
		file.mkdirs();
		}
		
		try {
			SpringApplication.run(NCRunApp.class, args);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
